package by.demchenko.sample.services.impl;

import by.demchenko.sample.dataaccess.base.AccountDao;
import by.demchenko.sample.datamodel.Account;
import by.demchenko.sample.datamodel.Person;
import by.demchenko.sample.services.AccountService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.util.DigestUtils;

import javax.inject.Inject;

@Service
public class AccountServiceImpl implements AccountService {

    private static final Logger LOGGER = LoggerFactory.getLogger(AccountServiceImpl.class);

    @Inject
    private AccountDao dao;

    @Override
    public Account get(Integer id) {
        return dao.getById(id);
    }

    @Override
    public Account Authorize(String login, String password) {
        //String md5Password = DigestUtils.md5DigestAsHex(password.getBytes());
        return dao.getAccountByCredentials(login, password);
    }

    @Override
    public boolean findLogin(String login) {
        return dao.findLogin(login);
    }

}